import { App } from "vue";
const exportLibraryFn = () => {
  const modules = import.meta.glob('./*.vue',
    { eager: true }
  );
  const list = Object.keys(modules)
  const nameList = list.map(item => {
    const modulePath = (modules[item] as any)
    const name = item.match(/\/([^/]+)$/)?.[1].split('.')[0]
    return { name: name, component: modulePath.default };
  })
  return nameList
}

const UI = {
  install(vue: App) {
    const nameList = exportLibraryFn()
    nameList.forEach((element) => {
      vue.component('H-' + (element.name), element.component)
    });
  }
}
export default UI